<?php $path = Yii::app()->theme->baseUrl . '/'; ?>
<!-- BEGIN SIDEBAR -->
<?php
$mini = " mini ";
$cont = Yii::app()->controller->id;
if( !empty( $cont ) )
{
	$action = Yii::app()->controller->action->id;
	if( $cont == "main" && ($action == "index" || $action == "") )
	{
		$mini = "";
	}
}
?>
<div class="page-sidebar <?php echo $mini; ?>" id="main-menu" data-inner-menu="1">
	<!-- BEGIN MINI-PROFILE -->
	<div class="user-info-wrapper">
		<div class="profile-wrapper">
			<?php echo CHtml::link('<img src="/uploads/images/users/'.Yii::app()->user->name[ 'userImage' ] . '" data-src="/uploads/images/users/' . Yii::app()->user->name[ 'userImage' ] . '" data-src-retina="/uploads/images/users/' . Yii::app()->user->name[ 'userImage' ] . '" width="69" height="69" />', array('users/view','id'=>Yii::app()->user->id)); ?>
		</div>
		<div class="user-info">
			<div class="greeting">Добро пожаловать</div>
			<div class="username">
				<?php echo CHtml::link('<strong>' . Yii::app()->user->name[ 'userName' ] . '</strong>', array('users/view','id'=>Yii::app()->user->id)); ?>
			</div>
			<div class="status">Статус<a href="#">
					<div class="status-icon green"></div>
					Вкл</a></div>
		</div>
	</div>
	<!-- BEGIN SIDEBAR MENU -->
	<p class="menu-title">BROWSE <span class="pull-right"><i class="icon-refresh"></i></span></p>
	<?php getMenu( $this->menu ); ?>

	<a href="#" class="scrollup">Scroll</a>
	<div class="clearfix"></div>
	<!-- END SIDEBAR MENU -->
</div>


<?php

function getMenu( $menus, $sub = false )
{
	static $icons = [
		'icon-custom-home',
		'icon-copy',
		'icon-indent-right',
		'icon-th-large',
		'icon-comments-alt',
		'icon-puzzle-piece',
		'icon-user-md',
		'icon-custom-chart',
		'icon-question',
		'icon-columns',
		'icon-search',
		'icon-exchange',
		'icon-reply',
		'icon-money',
	];

	if( empty( $menus ) )
		return;
	if( $sub )
	{
		echo '<ul class="sub-menu">';
	}
	else
	{
		echo "<ul>";
	}
	$count = 0;
	foreach( $menus as $title => $menu )
	{
		if( !is_array( $menu ) )
		{
			//$href = '/admin/' . $menu;
			echo '<li>';
			echo CHtml::link(((!$sub) ? '<i class="' . $icons[ $count++ ] . '"></i>' : '') . ((!$sub) ? '<span class="title">' : '') . $title . ((!$sub) ? '</span>' : ''), array($menu));
		}
		else
		{
			echo '<li> <a href="javascript:;"> <i class="' . $icons[ $count++ ] . '"></i> <span class="title">' . $title . '</span> <span class="arrow "></span> </a>';
			getMenu( $menu, true );
			echo '</li>';
		}
	}
	echo "</ul>";
}
?>
